home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1993, 1994 Marc Parmet.
- * This file is part of the Macintosh port of GNU Emacs.
- *
- * GNU Emacs is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
- #if defined(THINK_C)
- #include <MacHeaders>
- #else
- #include <Types.h>
- #include <Memory.h>
- #include <Quickdraw.h>
- #include <Windows.h>
- #include <TextEdit.h>
- #endif
-
- #include "stdio.h"
- #include "errno.h"
- #include "unix-constants.h"
- #include "unix-types.h"
-
- long
- fflush_internal(FILE *fp,struct savearea_lomem *lomem)
- {
- int n;
-
- if (!fp->base) return 0;
-
- if (fp->flag & _READ) {
- fp->cnt = 0;
- set_errno(fp->err = 0);
- return 0;
- }
- else {
- if (fp->fd < 0) return 0;
- n = read_write_internal(unix_write,fp->fd,(char *)fp->base,fp->cnt,lomem);
- if (n != fp->cnt) {
- set_errno(fp->err = EUNDOC);
- return EOF;
- }
- else {
- set_errno(fp->err = 0);
- fp->cnt = 0;
- return 0;
- }
- }
- }
-
- void
- fclose_internal(FILE *fp,struct savearea_lomem *lomem)
- {
- if (fp->flag == 0) return; // Is this statement necessary?
- fflush_internal(fp,lomem);
- if (fp->fd < 0) return;
- close_internal(current_process_index,fp->fd,lomem);
- fp->flag = 0;
- if (fp->base && !fp->external_base) DisposPtr((Ptr)fp->base);
- }
-